package com.abel.roommanager.provider;

import java.util.Map;
import org.apache.ibatis.jdbc.SQL;

import com.abel.roommanager.pojo.Room;

public class RoomFindSql {
   public String getSql(Map<String, Object> map) {
	   Room room=(Room) map.get("room");
	   int enableLiving=(int)map.get("enableLiving");
	   int index=(int)map.get("index");
	   int count=(int)map.get("count");
	   SQL sql=new SQL().SELECT("*").FROM("room");
	   if (room.getAddress()!=null&&room.getAddress().length()!=0) {
		sql.WHERE("address like '"+room.getAddress()+"'");
	}
	   if (enableLiving==1) {
		sql.WHERE("capacity>livenumber");
	}
	   if (room.getState()!=0) {
		sql.WHERE("state="+room.getState());
	}
	   if (room.getType()!=0) {
		sql.WHERE("type="+room.getType());
	}
	String sql1=   sql.toString()+" limit "+index+","+count;
	return sql1;
	
}
}
